﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DTO;
using DAL;

namespace BUS
{
   public class LOAI_BAI_VIETBUS
    {
        public static void insert(LOAI_BAI_VIET lbv)
        {
            LOAI_BAI_VIETDAL lbvdal = new LOAI_BAI_VIETDAL();
            lbvdal.Insert(lbv);
        }

        public static void update(LOAI_BAI_VIET lbv)
        {
            LOAI_BAI_VIETDAL lbvdal = new LOAI_BAI_VIETDAL();
            lbvdal.Update(lbv);
        }

        public static void update_status(LOAI_BAI_VIET lbv)
        {

            LOAI_BAI_VIETDAL lbvdal = new LOAI_BAI_VIETDAL();
            lbvdal.Update_status(lbv);
        }

        public static void Delete(int id)
        {

            LOAI_BAI_VIETDAL loaibvdal = new LOAI_BAI_VIETDAL();
            loaibvdal.Delete(id);
        }
        public static int CheckExist(int id)
        {
            int t = 0;
            LOAI_BAI_VIETDAL loaibv = new LOAI_BAI_VIETDAL();
            loaibv.Get("Where MA_LOAI_CHA = " + id.ToString(), 0, 0, Loaibvcolum.MA_LOAI_BV.ToString(), "ASC", out t);
            return t;
        }
        public static Loaibaivietcolection GET(string Where, int PageIndex, int PageSize,
                                       string OrderBy, string OrderDirection,
                                       out int TotalRecords)
        {

            LOAI_BAI_VIETDAL loaibvdal = new LOAI_BAI_VIETDAL();
            return loaibvdal.Get(Where, PageIndex, PageSize,
                            OrderBy, OrderDirection, out TotalRecords);
        }

        public static Loaibaivietcolection GetAll()
        {
            int t = 0;
            LOAI_BAI_VIETDAL loaibvdal = new LOAI_BAI_VIETDAL();
            return loaibvdal.Get("where 1=1", 0, 1000,
                Loaibvcolum.MA_LOAI_BV.ToString(), "DESC", out t);

        }
        public static LOAI_BAI_VIET GetByID(int iD)
        {
            int t = 0;
            LOAI_BAI_VIETDAL loaibvdal = new LOAI_BAI_VIETDAL();
            Loaibaivietcolection BAIVIETcollection = loaibvdal.Get("where " + Loaibvcolum.MA_LOAI_BV.ToString() + " = " + iD.ToString(), 0, 0,
                Loaibvcolum.TEN_LOAI_BV.ToString(), "ASC", out t);
            if (BAIVIETcollection.Count == 1)
                return BAIVIETcollection[0];
            return null;
        }
        public static string GetCha(int maloaicha)
        {
            int t = 0;
            LOAI_BAI_VIETDAL loaibvdal = new LOAI_BAI_VIETDAL();
            Loaibaivietcolection BAIVIETcollection = loaibvdal.Get("where " + Loaibvcolum.MA_LOAI_BV.ToString() + " = " + maloaicha.ToString(), 0, 0,
                Loaibvcolum.MA_LOAI_BV.ToString(), "ASC", out t);
            if (BAIVIETcollection.Count == 1)
                return BAIVIETcollection[0].Tenloai;
            return null;
        }
    }
}
